﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace RobotCtrl
{
    class TrackLine : Track
    {
        #region members

        #endregion

        #region constructor & deconstrucotor
        public TrackLine(float length, float speed, float acceleration)
        {
            this.length = Math.Abs(length);
            this.nominalSpeed = speed;
            this.acceleration = acceleration;
            this.reverse = (Math.Sign(length) ^ Math.Sign(speed)) != 0;
        }
        #endregion

        #region properties

        #endregion

        #region methods

        public override void IncrementalStep(float timeInterval, float newVelocity, out float leftSpeed, out float rightSpeed)
        {
            currentVelocity = newVelocity;

            if (reverse) newVelocity = -newVelocity;

            leftSpeed = -newVelocity;
            rightSpeed = newVelocity;
            DoStep(timeInterval);
        }

        #endregion
    }
}
